package com.xiguanlezz.cn.common;

import lombok.ToString;

/**
 * @Author：习惯了种种
 * @CreateDate：2024/10/16 23:04
 * @Description：消息请求实体类
 */
// callSuper为true表示要将父类中的成员变量也加入toString()方法中
@ToString(callSuper = true)
public class RequestMessage extends Message<Operation> {

    @Override
    protected Class getMessageBodyClass(int opType) {
        return OperationType.fromOpType(opType).getOperationClazz();
    }

    public RequestMessage() {

    }

    public RequestMessage(long msgId, Operation operation) {
        MessageHeader messageHeader = new MessageHeader(OperationType.fromOperation(operation).getOpType(), msgId);
        RequestMessage requestMessage = new RequestMessage();
        requestMessage.setMessageHeader(messageHeader);
        requestMessage.setMessageBody(operation);
        this.setMessageHeader(messageHeader);
        this.setMessageBody(operation);
    }
}
